<?php
/**
 * Enter description here ...
 * @author NgoAnhTu
 * @date 2013-11-02
 */
class AttachBusiness {
	
	const IMG_THUMB_WIDTH = 130;
	const IMG_THUMB_HEIGHT = 90;
	const IMG_MEDIUM = 400;
	const IMG_WIDTH = 693;
	
	private static $instance = null;
	
	/**
	 * Enter description here ...
	 * @var AttachmentDAO
	 */
	protected $attachmentDAO;
	
	/**
	 * Enter description here ...
	 * @var AttachDetailDAO
	 */
	protected $attachDetailDAO;
	
	/**
	 * AttachBusiness instance only
	 * @return AttachBusiness
	 */
	public static function getInstance() {
		if (self::$instance == null)
			self::$instance = new AttachBusiness();
		return self::$instance;
	}
		
	/**
	 * Constructor
	 */
	public function AttachBusiness() {
		$this->attachmentDAO = AttachmentDAO::getInstance();
		$this->attachDetailDAO = AttachDetailDAO::getInstance();
	}
	
	/**
	 * Search
	 * @param string $type
	 * @param string $pattern
	 * @param string $page
	 */
	public function search($type, $pattern, $page) {
		return $this->attachmentDAO->selectPage($page, DAO::PAGE_SIZE, "Type='$type' AND Name LIKE '%pattern%'", 'Name');
	}
}
?>